/**
 * Writed by yura and mak
 */

package wz.legend.handlers;

import org.apache.http.HttpEntity;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.contrib.compress.GzipDecompressingEntity;

import wz.legend.Context;
import wz.legend.HttpContext;



public class GzipHandler implements ResponseHandler {

    public void handle(HttpContext httpContext, Context context) {
        HttpEntity entity = httpContext.getResponse().getEntity();
        if (entity != null && entity.getContentEncoding() != null
                && entity.getContentEncoding().getValue().indexOf("gzip") != -1) {
            httpContext.getResponse().setEntity(new GzipDecompressingEntity(entity));
        }
    }
}
